#include <fasys/channels_container.hpp>

struct test
{
  int a;
  test():a(0){std::cout << "const" << std::endl;}
  test(test& t){ std::cout << "move" << std::endl;}
  test(const test& t){ std::cout << "copy" << std::endl;}
};

int test1(test t)
{
  test tt = t;
  return t.a;
};

int test2(test& t)
{
  test tt = t;
  t.a = 10;
  return t.a;
};

int test3(const test& t)
{
  test tt = t;
  return t.a;
};

int main()
{
  test t;
  std::cout<<"test1"<<std::endl;
  test1(t);
  std::cout<<"test2"<<std::endl;
  test2(t);
  std::cout<<"test3"<<std::endl;
  test3(t);
  std::cout << "-" << t.a << std::endl;
  fasys::channels_container cc;
  const fasys::channel_info& ci1 = cc.create("channel");
  if (!ci1) return 1;
  if (ci1.channel_id == 0) return 1;
  if (ci1.create_time != ci1.update_time) return 1;

  const fasys::channel_info& ci2 = cc.find("channel");
  if (!ci2) return 1;
  if (ci2.channel_id != ci1.channel_id) return 1;
  if (ci2.name != ci1.name) return 1;
  if (ci2.name != "channel") return 1;
  
  const fasys::channel_info& ci3 = cc.find(ci1.channel_id);
  if (!ci3) return 1;
  if (ci3.name != "channel") return 1;
  
  const fasys::channel_info& ci4 = cc.create("channel2");
  if (ci4.channel_id == ci1.channel_id) return 2;
  const fasys::channel_info& ci5 = cc.find(ci4.channel_id);
  if (ci5.name != "channel2") return 1;
  return 0;
}